<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Question extends Model
{
   	 	protected $table = 'question';
      public $timestamps = false;

       /**
        * 查找问题的话题
        */
       public function getTopicByQuestion()
       {
       	return $this->belongsToMany('App\Topic', 'topic_question', 'question_id', 'topic_id');
       }

       /**
        * 查找问题的回答
        */
       public function getAnswer()
       {
       	return $this->hasMany('App\Answer','question_id');
       }



    /**
     * 查找问题的关注数
     */
    public function getFocusByQuestion()
    {
        // return $this->hasMany('App\Questionfocus', 'question_id');
        return $this->belongsToMany('App\User', 'questionfocus', 'question_id', 'user_id')->withPivot('create_time');
    }
    

}
